Setup
-----
We integrate VAPI via SIP. Inbound calls arrive on a Twilio number that
SIP-dials sip.vapi.ai using
...
in our TwiML,
with a custom SIP header on the INVITE that identifies which assistant
should run. The corresponding phone number in VAPI has a Server URL
configured, and we return the assistant config dynamically per call
via the assistant-request message.
For resilience, we use Twilio's
callback to be
notified of every dial outcome. We classify based on DialCallStatus
and DialSipResponseCode: anything that's not "completed" / 200 OK is
treated as a failure, and we redirect the same call leg to a backup
voice provider. We treat SIP 486 and 503 specifically as capacity
rejections (RFC 3261 §21.4 / §21.5) so we can react differently to
them than other failures.
The problem
-----------
We can't get VAPI's SIP edge to return any non-2xx response. Every
failure mode we've tried still returns SIP 200 OK to the INVITE,
followed by an immediate hangup at the media layer (~1s typical).
From Twilio's wire view that's DialCallStatus=completed,
DialSipResponseCode=200, DialCallDuration=1 — indistinguishable from
a successful but very short call. Our classifier reads it as success,
and the failover never fires.